package com.example.demo.cookie;

import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 描述
 *
 * @author: yuy
 */

@RestController
public class LoginController {

    private static final String TOKENX = "1234";

    @PostMapping("login")
    public String queryPoolList(HttpServletResponse response,
                                @CookieValue(value = "token", required = false) String token) {
        if (token == null) {
            CookieUtils.writeCookie(response, "token", TOKENX);
        } else {
            System.out.println(token);
        }
        //返回前台
        return "成功";
    }
}

